package com.brzjomo.secretiveworld.object.item;

import java.util.List;

import com.brzjomo.secretiveworld.util.helper.KeyboardHelper;

import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;

public class WorldRoamBookItem extends Item {

	public WorldRoamBookItem(Properties properties) {
		super(properties);
	}
	
	//增加物品提示
	@Override
	public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
		if (KeyboardHelper.isHoldingShift()) {
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.world_roam_book_1"));
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.world_roam_book_2"));
		} else {
			tooltip.add(new TranslationTextComponent("tooltip.secretiveworld.world_roam_book_3"));
		}
		super.addInformation(stack, worldIn, tooltip, flagIn);
	}
	
	//测试用
	@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
		if (KeyboardHelper.isHoldingShift()) {
			//20为一秒
			playerIn.addPotionEffect(new EffectInstance(Effects.SPEED, 1200, 8));
			playerIn.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 1200, 5));
			playerIn.addPotionEffect(new EffectInstance(Effects.SLOW_FALLING, 1200, 1));
		}  else {
			playerIn.clearActivePotions();
		}
		return super.onItemRightClick(worldIn, playerIn, handIn);
	}
}
